<template>
  <div class="milk-article" :class="{'is-top-article':top}">
    <a href="javascript:void(0)" @click="readMore"
       class="milk-article-img"
       :style="{backgroundImage: value.cover?`url(${value.cover})`:`url(/image/article/demo-p1.jpg)`}"
    ></a>
    <div class="milk-article-body">
      <h4 class="article-heading"><a href="javascript:void(0)" @click="readMore">{{ value.title }}</a></h4>
      <div class="article-meta">
        <a href="javascript:void(0)"><span
            class="far fa-calendar-alt"></span><span>{{
            value.createTime.split('.')[0].split('T')[0]
          }}</span></a>
        <a href="javascript:void(0)">
          <span class="far fa-laugh-wink"></span><span>{{ value.user ? value.user[0].userName : 'Daisy' }}</span>
<!--          <span class="iconfont icon-mine"></span><span>{{ value.user ? value.user[0].userName : 'Daisy' }}</span>-->
        </a>
        <a href="javascript:void(0)"><span
            class="far fa-comment"></span><span>{{
            value.commentCount ? value.commentCount : 0
          }}</span></a>
      </div>
      <div class="article-preview">
        {{ value.description }}
      </div>
      <div class="article-more">
        <a href="javascript:void(0)" @click="readMore" class="article-link">More <i class="fa fa-arrow-right pl-4"></i></a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MilkArticle',
  props: {
    value: Object,
    top: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    readMore () {
      this.$router.push({
        path: '/article/' + this.value._id
      })
    }
  }
}
</script>

<style src="../../../common/css/article.css"></style>
<style>
.milk-article {
  display: flex;
  position: relative;
  width: 100%;
  padding: 24px 16px 16px 24px;
  margin-bottom: 40px;
  border-radius: 16px;
  box-shadow: 0 0 2rem 0 rgba(136, 152, 170, .15);
  border: 1px solid #e9e9f2;
  background-color: #FFFFFF;
  overflow: hidden;
}

.is-top-article:after{
  content:'T O P';
  font-family: hey_elsie_cuteregular;
  display: block;
  position: absolute;
  top: 10px;
  padding-left: 10px;
  right: -30px;
  width: 110px;
  height: 27px;
  line-height: 27px;
  border: 2px solid #c5a3ff;;
  font-size: 18px;
  font-weight: 600;
  background-color: #a175ed;
  color: white;
  text-align: center;
  transform: rotate(43deg);
}

.milk-article:hover {
  border-color: rgba(118, 109, 244, 0.35);
}

.milk-article-img {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  margin-right: 24px;
  background-size: cover;
}

.article-heading > a {
  color: #505050
}

.article-preview {
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
  padding: 14px 0;
  text-align: left;
  color: #515151;
}

.milk-article .iconfont {
  margin-right: 1px;
  font-size: 14px;
}

.article-more {
  overflow: hidden;
}

.article-link {
  display: inline-block;
  height: 28px;
  line-height: 28px;
  padding: 0 20px;
  color: #FFFFFF;
  float: right;
  border-radius: 12px;
  border: 2px solid #c5a3ff;
  background-color: #a175ed;
}

.article-link:hover {
  background-color: #c5a3ff;
}

@media (max-width: 768px) {
  .milk-article {
    padding: 0 0 16px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
  }

  .milk-article-img {
    width: 100%;
    height: 220px;
    border-radius: 0;
    margin: 0 -24px 14px;
  }

  .milk-article .article-meta{
    display: flex;
    justify-content: center;
  }

  .milk-article-body {
    padding: 0 24px;
  }
}
</style>
